// component/image_grid/image_grid.js
import Toast from 'tdesign-miniprogram/toast/index';
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        imageList: {
            type: Array,
            value: []
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        visible: false,
        showIndex: false,
        closeBtn: false,
        deleteBtn: false,
        images: [],
        index:0
    },

    /**
     * 组件的方法列表
     */
    methods: {
        clickHandle(e) {
            // console.log(e.currentTarget.dataset.index)
            this.setData({
                images:this.data.imageList,
                index:e.currentTarget.dataset.index,
                showIndex: true,
                visible: true,
            });
        },
        onChange(e) {
            const {
                detail: {
                    index
                },
            } = e;
            Toast({
                context: this,
                selector: '#t-toast',
                message: `翻到第${index + 1}个`,
            });
        },

        // onDelete(e) {
        //     const {
        //         detail: {
        //             index
        //         },
        //     } = e;
        //     Toast({
        //         context: this,
        //         selector: '#t-toast',
        //         message: `删除第${index + 1}个`,
        //     });
        // },

        onClose(e) {
            const {
                detail: {
                    trigger
                },
            } = e;
            if (trigger === 'overlay') {
                Toast({
                    context: this,
                    selector: '#t-toast',
                    message: '点击overlay关闭',
                });
            } else if (trigger === 'button') {
                Toast({
                    context: this,
                    selector: '#t-toast',
                    message: `点击button关闭`,
                });
            }
            this.setData({
                visible: false,
            });
        },
    },
});